package chapter3;

public class Ex2 {
    private int length;
    private int width;


    public Ex2(int length, int width) {
        this.length = length;
        this.width = width;
    }

    public Ex2() {

    }

    public int getLength() {
        return length;
    }

    public void setLength(int length) {
        if(length<50&&length>0){
            this.length = length;
        }
        else{
            System.out.println("无法输出");
        }
    }

    public int getWidth() {
        return width;
    }

    public void setWidth(int width) {
       if(width<50&&width>0){
           this.width = width;
       }
       else {
           System.out.println("无法输出");
       }

    }

    public int getArea(){
        return length*width;
    }
    public int getPerimeter(){
        return length*2+width*2;
    }

}
